#! /bin/bash
sudo apt-get update -y

## Installing Zulu Azure JDK 8
sudo apt-get -y --no-install-recommends install dirmngr gnupg software-properties-common
sudo apt-get -y dist-upgrade
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
sudo apt-add-repository "deb http://repos.azul.com/azure-only/zulu/apt stable main"
sudo apt-get update -y
sudo apt-get -y --no-install-recommends install zulu-8-azure-jdk
echo "export JAVA_HOME=/usr/lib/jvm/zulu-8-azure-amd64" >> /etc/bash.bashrc

sudo apt-get install maven -y
sudo mvn install

# persist this variable to the VM environment
echo "JAVA_OPTIONS=$JAVA_OPTS" >> /etc/environment
echo "MAVEN_OPTS=$JAVA_OPTS" >> /etc/environment

# set MAVEN_OPTS for hazelcast service
sudo systemctl import-environment MAVEN_OPTS

# create the hazelcast home directory
sudo mkdir /var/hazelcast
sudo cp pom.xml /var/hazelcast
sudo cp ./hazelcast.xml /var/hazelcast/
